(function () {
  if (!window.console) {
    window.console = {
      log: function () { }
    }
  }
  var restArguments = function (func, startIndex) {
    startIndex = startIndex == null ? func.length - 1 : +startIndex;
    return function () {
      var length = Math.max(arguments.length - startIndex, 0)
        , rest = Array(length)
        , index = 0;
      for (; index < length; index++) {
        rest[index] = arguments[index + startIndex]
      }
      switch (startIndex) {
        case 0:
          return func.call(this, rest);
        case 1:
          return func.call(this, arguments[0], rest);
        case 2:
          return func.call(this, arguments[0], arguments[1], rest)
      }
      var args = Array(startIndex + 1);
      for (index = 0; index < startIndex; index++) {
        args[index] = arguments[index]
      }
      args[startIndex] = rest;
      return func.apply(this, args)
    }
  };
  window.utils = {};
  utils.now = Date.now || function () {
    return (new Date).getTime()
  }
    ;
  utils.delay = restArguments(function (func, wait, args) {
    return setTimeout(function () {
      return func.apply(null, args)
    }, wait)
  });
  utils.throttle = function (func, wait, options) {
    var timeout, context, args, result;
    var previous = 0;
    if (!options)
      options = {};
    var later = function () {
      previous = options.leading === false ? 0 : utils.now();
      timeout = null;
      result = func.apply(context, args);
      if (!timeout)
        context = args = null
    };
    var throttled = function () {
      var now = utils.now();
      if (!previous && options.leading === false)
        previous = now;
      var remaining = wait - (now - previous);
      context = this;
      args = arguments;
      if (remaining <= 0 || remaining > wait) {
        if (timeout) {
          clearTimeout(timeout);
          timeout = null
        }
        previous = now;
        result = func.apply(context, args);
        if (!timeout)
          context = args = null
      } else if (!timeout && options.trailing !== false) {
        timeout = setTimeout(later, remaining)
      }
      return result
    };
    throttled.cancel = function () {
      clearTimeout(timeout);
      previous = 0;
      timeout = context = args = null
    }
      ;
    return throttled
  }
    ;
  utils.debounce = function (func, wait, immediate) {
    var timeout, result;
    var later = function (context, args) {
      timeout = null;
      if (args)
        result = func.apply(context, args)
    };
    var debounced = restArguments(function (args) {
      if (timeout)
        clearTimeout(timeout);
      if (immediate) {
        var callNow = !timeout;
        timeout = setTimeout(later, wait);
        if (callNow)
          result = func.apply(this, args)
      } else {
        timeout = utils.delay(later, wait, this, args)
      }
      return result
    });
    debounced.cancel = function () {
      clearTimeout(timeout);
      timeout = null
    }
      ;
    return debounced
  }
    ;
  utils.shuffle = function shuffle(array) {
    var m = array.length, t, i;
    while (m) {
      i = Math.floor(Math.random() * m--);
      t = array[m];
      array[m] = array[i];
      array[i] = t
    }
  }
    ;
  utils.isIE = function isIE(ver) {
    var b = document.createElement("b");
    b.innerHTML = "\x3c!--[if IE " + ver + "]><i></i><![endif]--\x3e";
    return b.getElementsByTagName("i").length === 1
  }
    ;
  utils.parseTernary = function parseTernary(arg) {
    var num = arg;
    try {
      num = parseFloat(num);
      if (isNaN(num)) {
        return arg
      }
      var numArr = num.toString().split(".");
      numArr[0] = numArr[0].split("").reverse().join("").replace(/(\d{3})/g, "$1,").replace(/,$/, "").split("").reverse().join("");
      return numArr.length === 1 ? numArr[0] : numArr[0] + "." + numArr[1]
    } catch (e) {
      return arg
    }
  }
    ;
  utils.fmtDate = function fmtDate(obj) {
    var date = new Date(obj);
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? "0" + m : m;
    var d = date.getDate();
    d = d < 10 ? "0" + d : d;
    var h = date.getHours();
    h = h < 10 ? "0" + h : h;
    var minute = date.getMinutes();
    minute = minute < 10 ? "0" + minute : minute;
    return y + "-" + m + "-" + d + " " + h + ":" + minute
  }
    ;
  utils.initFixDia = function (id) {
    var timeMap = JSON.parse(localStorage.getItem("fixDiaInfo") || "{}");
    var time = timeMap[id];
    var show = true;
    if (time) {
      if (parseInt(time) <= (new Date).getTime()) {
        $("[data-diaid='" + id + "']").show()
      } else {
        show = false;
        $("[data-diaid='" + id + "']").remove()
      }
    } else {
      $("[data-diaid='" + id + "']").show()
    }
    return show
  }
    ;
  utils.closeFixDia = function (id, dayNum) {
    $("[data-diaid='" + id + "']").remove();
    var timeMap = JSON.parse(localStorage.getItem("fixDiaInfo") || "{}");
    var aim = new Date((new Date).getTime() + (dayNum ? dayNum : 1) * 24 * 60 * 60 * 1e3);
    timeMap[id] = new Date(aim.getFullYear() + "/" + (aim.getMonth() + 1) + "/" + aim.getDate()).getTime();
    localStorage.setItem("fixDiaInfo", JSON.stringify(timeMap))
  }
    ;
  utils.countPwdScore = function countPwdScore(s) {
    if (!s)
      return "weak";
    var a = "weak"
      , len = s.length;
    if (len < 8) {
      a = "weak"
    } else {
      var count1 = 0
        , count2 = 0
        , count3 = 0;
      for (var i = 0; i < len; i++) {
        if ("A" <= s.charAt(i) && s.charAt(i) <= "Z" || "a" <= s.charAt(i) && s.charAt(i) <= "z") {
          count1 = 1
        } else if (s.charAt(i) >= "0" && s.charAt(i) <= "9") {
          count2 = 1
        } else {
          count3 = 1
        }
      }
      if (count1 + count2 + count3 == 3) {
        a = "secure"
      } else if (count1 + count2 + count3 == 2) {
        a = "average"
      } else {
        a = "weak"
      }
    }
    return a
  }
    ;
  utils.NumberToMoney = function (val) {
    val = parseFloat(val).toString();
    if (isNaN(val) || val == null || val.toString().trim() == "") {
      val = "0"
    }
    var res = val.indexOf(".") !== -1 ? val.replace(/(\d{1,3})(?=(\d{3})+\.)/g, "$1,") : val.replace(/(\d)(?=(?:\d{3})+$)/g, "$1,");
    return res
  }
}
)();
var oy_ajax = function oy_ajax(opts) {
  var options = $.extend({}, opts);
  options.success = function (data) {
    if (data.code == 200) {
      opts.success(data.data)
    } else if (data.code == 401) {
      if (wyComponent && wyComponent.login) {
        wyComponent.login.show(function () {
          options.loginCb && options.loginCb()
        })
      }
    } else {
      opts.statusErr && opts.statusErr(data);
      layer.msg(data.message, {
        icon: 2
      })
    }
  }
    ;
  options.error = function () {
    layer.msg("系统出错，请刷新重试！");
    opts.error && opts.error();
    opts.statusErr && opts.statusErr()
  }
    ;
  $.ajax(options)
};
var oy_statics = {
  useOperateLog: function (productId, Type, productCode) {
    $.ajax({
      url: oy_global.ctx + "/save/user_operate_log",
      dataType: "json",
      type: "post",
      data: {
        type: Type,
        dataId: productId,
        code: productCode
      },
      success: function () { }
    })
  }
};
(function () {
  var callbackMap = {};
  window.oy_callback = {
    setCallback: function (type, func) {
      if (!(typeof type === "string") || !(typeof func === "function")) {
        return false
      }
      if (!callbackMap[type]) {
        callbackMap[type] = [];
        callbackMap[type].push(func)
      } else {
        callbackMap[type].push(func)
      }
    },
    doCallback: function (type, data) {
      if (type === undefined)
        return false;
      for (var i = 0, arr = callbackMap[type]; i < arr.length; i++) {
        arr[i](!!data ? data : undefined)
      }
    },
    clearCallback: function (type) {
      if (type === undefined)
        return false;
      delete callbackMap[type]
    }
  }
}
)();
(function () {
  window.app_bankImagesJson = {
    "中国银行": "/static/mobile/images/bank/bank-01.png",
    "工商银行": "/static/mobile/images/bank/bank-02.png",
    "建设银行": "/static/mobile/images/bank/bank-03.png",
    "农业银行": "/static/mobile/images/bank/bank-04.png",
    "兴业银行": "/static/mobile/images/bank/bank-05.png",
    "招商银行": "/static/mobile/images/bank/bank-06.png",
    "交通银行": "/static/mobile/images/bank/bank-07.png",
    "平安银行": "/static/mobile/images/bank/bank-08.png",
    "民生银行": "/static/mobile/images/bank/bank-09.png",
    "中信银行": "/static/mobile/images/bank/bank-10.png",
    "光大银行": "/static/mobile/images/bank/bank-11.png",
    "浦发银行": "/static/mobile/images/bank/bank-12.png",
    "邮储银行": "/static/mobile/images/bank/bank-13.png",
    "华夏银行": "/static/mobile/images/bank/bank-14.png",
    "北京银行": "/static/mobile/images/bank/bank-16.png",
    "宁波银行": "/static/mobile/images/bank/bank-17.png",
    "广发银行": "/static/mobile/images/bank/bank-20.png"
  };
  (function () {
    if (window.layer) {
      var NUM = 0;
      var lyIndex = -1;
      window.layer.g_load = function (hasShade) {
        if (hasShade == undefined) {
          hasShade = .1
        }
        if (NUM < 0) {
          NUM = 0;
          lyIndex = layer.load(2, {
            shade: hasShade
          })
        } else if (NUM === 0) {
          lyIndex = layer.load(2, {
            shade: hasShade
          })
        }
      }
        ;
      window.layer.g_closeload = function () {
        NUM--;
        if (NUM <= 0) {
          layer.close(lyIndex)
        }
      }
        ;
      var LAZY_NUM = 0;
      var lazyClock = 0;
      window.layer.g_lazyload = function (time, hasShade) {
        LAZY_NUM++;
        clearTimeout(lazyClock);
        lazyClock = setTimeout(function () {
          layer.g_load(hasShade)
        }, time || 2e3)
      }
        ;
      window.layer.g_closeLazyload = function (clock) {
        LAZY_NUM--;
        if (LAZY_NUM <= 0) {
          clearTimeout(lazyClock);
          layer.g_closeload()
        }
      }
    }
  }
  )();
  (function (factory) {
    if (typeof define === "function" && define.amd) {
      define(["jquery"], factory)
    } else {
      factory(window.jQuery || window.$)
    }
  }
  )(function ($) {
    function setCount(ele, opt) {
      if ($(ele).attr("count-init")) {
        return false
      }
      var $element = $(ele);
      var defaults = {
        time: 60,
        tipBefore: "",
        tipAfter: "秒后重新发送",
        countClass: "is-counting",
        countBefore: function () { },
        countAfter: function () { },
        srcWrd: $element.html()
      };
      var options = $.extend({}, defaults, opt);
      var clock = 0;
      function count(second) {
        var count = second || options.time;
        clearInterval(clock);
        $element.addClass(options.countClass).html(options.tipBefore + count + options.tipAfter);
        options.countBefore();
        clock = setInterval(function () {
          if (count <= 0) {
            $element.removeClass(options.countClass).html(options.srcWrd);
            clearInterval(clock);
            options.countAfter()
          } else {
            count--;
            $element.html(options.tipBefore + count + options.tipAfter)
          }
        }, 1e3)
      }
      $element.on("count:reset", function () {
        $element.removeClass(options.countClass).html(options.srcWrd);
        clearInterval(clock)
      });
      $element.on("count:start", function (event, second) {
        count(second)
      });
      $element.attr("count-init", "true")
    }
    jQuery.fn.extend({
      countDown: function (opt) {
        return this.each(function () {
          setCount(this, opt);
          return this
        })
      }
    })
  });
  $.fn.srhSelect = function () {
    function setSrhSlc(ele) {
      var $this = $(ele);
      var $select = $this.find("[data-id='select-dom']");
      var options = $select[0].options;
      var $srh = $this.find("[data-id='select-srh']");
      var $show = $('<div  class="m-select-show"></div> ');
      var $ul = $("<ul class='slc-ul'></ul>");
      var width = $select.outerWidth() + 20;
      $this.css({
        minWidth: width + "px"
      });
      $this.append($ul);
      $this.prepend($show);
      $ul.css({
        width: width + "px"
      });
      $show.css({
        width: width + "px"
      });
      $select.css({
        width: "0px"
      });
      $srh.css({
        width: width + "px"
      });
      for (var i = 0; i < options.length; i++) {
        (function () {
          var curI = i;
          var $li = $('<li data-value="' + options[curI].value + '">' + options[curI].text + "</li>");
          $ul.append($li)
        }
        )()
      }
      function show() {
        $srh.css({
          display: "block"
        }).focus();
        $ul.css({
          display: "block"
        })
      }
      function hide() {
        $srh.css({
          display: "none"
        });
        $ul.css({
          display: "none"
        })
      }
      $ul.on("click", "li", function (e) {
        options[$(this).index()].selected = true;
        $select.trigger("change");
        $("body").trigger("click");
        e.stopPropagation()
      });
      var $liList = $ul.find("li");
      function changeEv() {
        $ul.find(".is-active").removeClass("is-active");
        $select.find("option:selected").each(function () {
          $liList.eq(this.index).addClass("is-active")
        });
        var $slcLis = $ul.find(".is-active");
        $show.text($slcLis.length === 0 ? $ul.find("li").eq(0).text() : $slcLis.eq(0).text())
      }
      $select.on("change", changeEv);
      changeEv();
      if ($srh.length !== 0) {
        $srh.on("keyup", function () {
          for (var j = 0; j < $liList.length; j++) {
            var $li = $liList.eq(j);
            var key = this.value;
            if (new RegExp(key, "gi").test($li.text())) {
              $li.removeClass("is-hidden")
            } else {
              $li.addClass("is-hidden")
            }
          }
        })
      }
      $show.on("click", function () {
        show();
        $select.click();
        $("body").one("click", function (e) {
          hide()
        })
      });
      $this.on("click", function (e) {
        e.stopPropagation()
      })
    }
    this.each(function () {
      setSrhSlc(this)
    });
    return this
  }
    ;
  $.fn.modSelect = function () {
    function setModSlc(ele) {
      var $this = $(ele);
      var $select = $this.find("[data-id='select-dom']");
      var $show = $('<div class="m-select-show"></div>');
      var width = $select.outerWidth() + 2;
      $this.css({
        minWidth: width + "px"
      });
      $this.prepend($show);
      $show.css({
        width: width + "px"
      });
      $show.html($select.find("option:selected").val() || "");
      $select.on("change", function () {
        $show.html($select.find("option:selected").val() || "")
      })
    }
    this.each(function () {
      setModSlc(this)
    });
    return this
  }
    ;
  $.validator.addMethod("phone", function (value, element) {
    return this.optional(element) || /^(1[0-9][0-9]{9})$/i.test(value)
  }, "手机号码格式不正确！");
  $.validator.addMethod("wyemail", function (value, element) {
    return this.optional(element) || /^[a-zA-Z0-9._%-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}$/i.test(value)
  }, "邮箱格式不正确！");
  $.validator.addMethod("unEqualTo", function (value, element, param) {
    var target = $(param);
    if (this.settings.onfocusout && target.not(".validate-equalTo-blur").length) {
      target.addClass("validate-equalTo-blur").on("blur.validate-equalTo", function () {
        $(element).valid()
      })
    }
    return !(value === target.val())
  }, "请输入不同的值!");
  $.validator.addMethod("vatNumber", function (value, element) {
    return this.optional(element) || /^[0-9a-zA-Z]+$/.test(value)
  }, "税务登记号格式不正确！");
  $.validator.addMethod("peopleNameCheck", function (value, element) {
    return this.optional(element) || !/^[A-z]+$/.test(value)
  }, "不能全是英文字母！");
  window.wyComponent = {
    showBigPic: function (img) {
      var $img = $(img)
        , imgSrc = $img.attr("src") ? $img.attr("src") : oy_global.defaultProImg
        , imgObj = new Image
        , styImg = "";
      imgObj.src = imgSrc;
      var diaHeight = Math.min($(window).height() - 100, 800)
        , diaWidth = Math.min($(window).width() - 100, 960);
      layer.open({
        type: 1,
        title: "查看大图",
        content: '<div style="padding: 15px;width: 100%;line-height:1;height: ' + (diaHeight - 48) + 'px;text-align: center;"><img style="max-width: 94%;max-height: 94%;vertical-align: middle;display: inline-block;" src="' + imgSrc + '"/><span style="height:100%;width: 0px;display:inline-block;vertical-align: middle;"></span></div>',
        area: [diaWidth + "px", diaHeight + "px"],
        shadeClose: true
      })
    },
    login: {
      show: function (callback) {
        if (oy_global.isLogin) {
          callback && callback()
        } else {
          layer.msg("请先登录！", {
            icon: 7
          });
          setTimeout(function () {
            location.href = oy_global.user.loginUrl
          }, 2e3)
        }
      }
    },
    previewPdf: function (id, name) {
      if (!id)
        return false;
      function init() {
        $("body").append('<div data-id="" class="c-pdfDia" data-index="0" id="c-pdf_dia"><ul id="c-pdf_list"></ul><iframe id="c-pdf_ifr" width="100%"></iframe></div>');
        $("#c-pdf_list").on("click", ".js-preview", function () {
          if ($(this).parent().hasClass("is-active"))
            return false;
          var index = $("#c-pdf_dia").data("index");
          $("#c-pdf_list").find(">li").eq(index).removeClass("is-active").find(".js-preview em").text("点击预览");
          $("#c-pdf_dia").data("index", $(this).data("index"));
          $(this).find("em").text("当前预览");
          $(this).parent().addClass("is-active");
          $("#c-pdf_ifr").attr("src", "https://uploadcdn.oneyac.com/spec_file/pdfjs/web/viewer.html?file=" + $(this).data("url"))
        });
        $("#c-pdf_list").on("click", ".js-count", function () {
          oy_statics.useOperateLog($(this).data("id"), "PDF_DOWN")
        })
      }
      if (!$("#c-pdf_dia")[0]) {
        init()
      }
      function openIfr(proName) {
        var diaH = $(window).height() - 100;
        layer.open({
          type: 1,
          title: (!!proName ? proName : "") + "数据手册",
          content: $("#c-pdf_dia"),
          area: ["830px", diaH + "px"],
          maxmin: true,
          success: function () {
            $("#c-pdf_ifr").css({
              height: diaH - $("#c-pdf_list").outerHeight() - 46 + "px"
            })
          },
          full: function () {
            $("#c-pdf_list").addClass("is-full");
            $("#c-pdf_ifr").css({
              height: $(window).height() - $("#c-pdf_list").outerHeight() - 46 + "px"
            })
          },
          restore: function () {
            $("#c-pdf_list").removeClass("is-full");
            $("#c-pdf_ifr").css({
              height: diaH - $("#c-pdf_list").outerHeight() - 46 + "px"
            })
          },
          cancel: function () {
            $("#c-pdf_list").removeClass("is-full");
            $("#c-pdf_ifr").css({
              height: diaH - $("#c-pdf_list").outerHeight() - 46 + "px"
            })
          }
        })
      }
      function load(proId, proName) {
        if (proId == $("#c-pdf_dia").data("id")) {
          openIfr(proName);
          return false
        }
        var loadInx = layer.g_lazyload();
        $.ajax({
          url: oy_global.ctx + "/product/ajax_find_attachment",
          data: {
            id: proId
          },
          success: function (data) {
            $("#c-pdf_dia").data("id", proId);
            var html_list = "";
            layer.g_closeLazyload(loadInx);
            if (!data || data.length == 0) {
              layer.msg("暂无相关数据手册！");
              return false
            }
            for (var i = 0; i < data.length; i++) {
              html_list += '<li class="c-pdf_itm ' + (i == 0 ? "is-active" : "") + '">';
              html_list += '<span class="js-preview" data-index="' + i + '" data-url="' + encodeURIComponent(data[i].fullUrl) + '"><i class="iconfont icon-eye"></i><em>' + (i == 0 ? "当前预览" : "点击预览") + "</em></span>";
              html_list += '<p><i class="iconfont icon-filepdf"></i>&nbsp;<em>' + data[i].fileName + "</em></p>";
              html_list += '<a data-id="' + proId + '" class="js-count text-primary" href="' + data[i].fullUrl + '" target="_blank"><i class="iconfont icon-download"></i><em>直接下载</em></a>';
              html_list += "</li>"
            }
            $("#c-pdf_list").html(html_list);
            $("#c-pdf_ifr").attr("src", "https://uploadcdn.oneyac.com/spec_file/pdfjs/web/viewer.html?file=" + encodeURIComponent(data[0].fullUrl));
            $("#c-pdf_dia").data("index", "0");
            openIfr(proName)
          },
          error: function () {
            layer.g_closeLazyload(loadInx);
            layer.msg("系统出错请重试！", {
              icon: 2
            })
          }
        })
      }
      if (window.oy_global.needPdfLogin == 1) {
        wyComponent.login.show(function () {
          load(id, name)
        })
      } else {
        load(id, name)
      }
    }
  };
  function setPlaceHolder() {
    var isOperaMini = Object.prototype.toString.call(window.operamini) === "[object OperaMini]";
    var isInputSupported = "placeholder" in document.createElement("input") && !isOperaMini;
    var isTextareaSupported = "placeholder" in document.createElement("textarea") && !isOperaMini;
    if (isInputSupported && isTextareaSupported) {
      $.fn.placeholder = function () {
        return this
      }
    } else {
      $.fn.placeholder = function () {
        return this.filter((isInputSupported ? "textarea" : ":input") + "[placeholder]").not(":radio, :checkbox, [type=hidden]").each(function () {
          var $this = $(this);
          var text = $this.attr("placeholder");
          var $tip = $("<span class='ie-inputTip' data-content='" + text + "'></span>");
          $this.before($tip);
          var top = ($this.outerHeight() - 20) / 2;
          var fontSize = parseFloat($this.css("fontSize").replace("px", ""));
          if ($this.is(":hidden")) {
            top = ($this.height() - 20) / 2
          }
          if ($this.prop("nodeName") === "TEXTAREA") {
            top = parseFloat($this.css("paddingTop").replace("px", ""))
          }
          $tip.css({
            fontSize: fontSize + "px",
            left: $this.css("paddingLeft"),
            "float": "left",
            top: top + "px"
          });
          $tip.on("click", function () {
            $this.focus()
          });
          $this.on("focus", function () {
            $tip.addClass("is-focus")
          });
          $this.on("blur", function () {
            $this.val() !== "" ? $tip.addClass("is-focus") : $tip.removeClass("is-focus")
          });
          $this.on("change", function () {
            $this.val() !== "" ? $tip.addClass("is-focus") : $tip.removeClass("is-focus")
          });
          $this.val() !== "" ? $tip.addClass("is-focus") : $tip.removeClass("is-focus")
        })
      }
    }
  }
  function initPageEvents() {
    $("[w-tips]").each(function () {
      var tipOptions = {
        tips: "这是一个tips层！",
        type: 1,
        bgcolor: "#0269c2"
      };
      var $this = $(this);
      var attr = $this.attr("w-tips");
      var args = {};
      var layerIndex = 0;
      attr = attr.replace(/\n/g, "<br/>");
      attr = attr.replace(/\t|\r/g, "&nbsp;");
      args = eval("(" + attr + ")");
      args = $.extend(true, tipOptions, args);
      $this.on("mouseover", function () {
        layerIndex = layer.open({
          type: 4,
          closeBtn: 0,
          content: [args.tips, this],
          shade: 0,
          tips: [args.type, args.bgcolor]
        })
      });
      $this.on("mouseleave", function () {
        layer.close(layerIndex)
      })
    })
  }
  function initCartPreview() {
    if (!$("#c-cart-preview")[0])
      return false;
    var $preview = $("#c-cart-preview");
    $preview.append('<div class="oy-cart_dropdown"><div class="oy-cart_main"><div class="oy-cart_goods"><table><thead><tr><th>型号</th><th>自定义料号</th><th>单价(含税)</th><th>数量</th><th>合计</th><th>&nbsp;</th></tr></thead><tbody class="js-list"></tbody></table></div><div class="oy-cart_stat"><table><tr><td style="width: 0;padding-right: 20px;" class="js-freight _txt-warning"></td><td>共 <span class="_txt-warning js-num">-</span> 件，总计：￥<span class="_txt-warning js-total"></span></td><td style="text-align: right;padding-left: 15px;"><a class="_btn _btn-primary" href="/cart.html">去购物车结算</a></td></tr></table></div></div><div class="oy-cart_empty"><i class="iconfont icon-cartEmpty"></i><br><p>您的购物车为空！请先选择您要购买的型号</p></div></div>');
    var $list = $preview.find(".js-list")
      , $freight = $preview.find(".js-freight")
      , $num = $preview.find(".js-num")
      , $total = $preview.find(".js-total")
      , allowLoad = true
      , loadTimeout = 0;
    function getList() {
      $(".oy-cart_dropdown").addClass("is-loading");
      $.ajax({
        url: oy_global.ctx + "/cart/list_ajax",
        type: "get",
        success: function (data) {
          if (data.count == 0) {
            $(".oy-cart_main").hide();
            $(".oy-cart_empty").show()
          } else {
            $num.html(data.count);
            $total.html(utils.parseTernary(data.totalPrice));
            $freight.html(data.subFreeFreight == 0 ? "已满足顺丰包邮" : "还差" + data.subFreeFreight + "元顺丰包邮");
            var html = "";
            for (var i = 0, list = data.list; i < list.length; i++) {
              html += "<tr" + (list[i].valid ? "" : ' class="is-unvalid"') + '><td><a href="' + list[i].proUrl + '" target="_blank" title="' + list[i].code + '" class="omit omit-15">' + (list[i].code || "") + (list[i].valid ? "" : "[失效]") + '</a></td><td><span class="omit omit-10" title="' + list[i].customCode + '">' + (list[i].customCode ? list[i].customCode : "--") + "</span></td><td>" + (list[i].unitPrice ? "￥" + list[i].unitPrice : "--") + "</td><td>" + (utils.NumberToMoney(list[i].count) || "") + "</td><td>" + (list[i].totalPrice ? '<span class="_txt-warning">￥' + utils.NumberToMoney(list[i].totalPrice) + "</span>" : "--") + '</td><td class="is-del"><a href="javascript:void(0);" data-id="' + list[i].id + '" class="js-del iconfont icon-x"></a></td></tr>'
            }
            $list.html(html);
            $(".oy-cart_main").show();
            $(".oy-cart_empty").hide()
          }
          $(".oy-cart_dropdown").removeClass("is-loading")
        },
        error: function () {
          layer.msg("购物车预览失败，请稍后重试！");
          $(".oy-cart_dropdown").removeClass("is-loading");
          $(".oy-cart_main").hide();
          $(".oy-cart_empty").show()
        }
      })
    }
    $preview.on("mouseover", function () {
      $preview.addClass("is-showlist");
      clearTimeout(loadTimeout);
      if (allowLoad) {
        allowLoad = false;
        getList()
      }
    });
    $preview.on("mouseleave", function () {
      $preview.removeClass("is-showlist");
      loadTimeout = setTimeout(function () {
        allowLoad = true
      }, 1500)
    });
    $list.on("click", ".js-del", function () {
      $.ajax({
        url: oy_global.ctx + "/cart/delete_ajax",
        dataType: "json",
        data: {
          cartIds: $(this).data("id")
        },
        type: "post",
        success: function () {
          getList();
          countCart()
        },
        error: function () {
          layer.msg("删除失败，请稍后重试！")
        }
      })
    })
  }
  var setTopBar = function setTopBar() {
    function setFixTit() {
      if (!$("#header")[0])
        return false;
      var flag = "";
      $("#header").on("destory:fixed", function () {
        $(window).off("scroll", setStatus);
        $("#header").removeClass("is-fixed")
      });
      var aimH = $("#header_pos").offset().top + $("#header_pos").height();
      var setStatus = utils.throttle(function () {
        if ($(window).scrollTop() > aimH) {
          if (flag !== "fixed") {
            $("#header").addClass("is-fixed");
            flag = "fixed"
          }
        } else {
          if (flag !== "static") {
            $("#header").removeClass("is-fixed");
            flag = "static"
          }
        }
      }, 200);
      setStatus();
      $(window).on("scroll", setStatus)
    }
    setFixTit();
    function setSrhhot() {
      if ($(".oy-srh_hot").find("li").length < 2)
        return false;
      var cur = 0
        , $ul = $(".oy-srh_hot").find("ul");
      $ul.append($ul.find("li").eq(0).clone(true));
      var clock = 0;
      function autoMove() {
        clock = setInterval(function () {
          if (cur == -56) {
            $ul.css({
              top: 0
            });
            cur = 0
          }
          $ul.animate({
            top: cur - 28 + "px"
          }, 500, "swing", function () {
            cur = cur - 28
          })
        }, 5e3)
      }
      autoMove();
      $(".oy-srh_hot").on("mouseover", function () {
        clearInterval(clock)
      });
      $(".oy-srh_hot").on("mouseleave", function () {
        autoMove()
      })
    }
    setSrhhot();
    function setSrh() {
      var $srh = $("#c-srh");
      if (!$srh[0])
        return false;
      var hisString = localStorage.getItem("srhHistory")
        , hisList = Boolean(hisString) ? JSON.parse(hisString) : []
        , $key = $(".oy-srh_inp")
        , _type = $srh.data("type")
        , _target = $srh.data("target");
      if (_type == "channel") {
        $srh.submit(function () {
          $key.val($key.val().trim());
          var key = $key.val();
          if (key.length < 2) {
            layer.msg("搜索关键字不能小于二个字符！", {
              icon: 2
            });
            return false
          }
          if (key.length > 50) {
            layer.msg("搜索关键字不能大于五十个字符！", {
              icon: 2
            });
            return false
          }
        });
        return false
      }
      $srh.submit(function () {
        $key.val($key.val().trim());
        var key = $key.val();
        if (key.length < 2) {
          layer.msg("搜索关键字不能小于二个字符！", {
            icon: 2
          });
          return false
        }
        if (key.length > 50) {
          layer.msg("搜索关键字不能大于五十个字符！", {
            icon: 2
          });
          return false
        }
        var ecKey = encodeURI(key);
        for (var i = 0; i < hisList.length; i++) {
          if (ecKey == hisList[i]) {
            hisList.splice(i, 1);
            break
          }
        }
        hisList.splice(0, 0, ecKey);
        if (hisList.length > 10) {
          hisList.splice(hisList.length - 1, 1)
        }
        localStorage.setItem("srhHistory", JSON.stringify(hisList));
        if (_target == "_blank") {
          window.open(oy_global.ctx + "/search.html?keyword=" + ecKey);
          return false
        }
      });
      var hideTip = localStorage.getItem("toSrhTip");
      if (!hideTip) {
        $key.on("keyup", utils.debounce(function () {
          !$key.val().trim() ? $(".oy-srh_tip").removeClass("is-show") : $(".oy-srh_tip").addClass("is-show")
        }, 200));
        $(".oy-srh_tip").find(".icon-x-bold").on("click", function () {
          $(".oy-srh_tip").remove();
          localStorage.setItem("toSrhTip", "yes")
        })
      }
      var $sug = $(".oy-srh_sug")
        , $list = $sug.find("ul")
        , hideTimer = 0
        , intervalFunc = 0
        , intervalTime = 700
        , key_res = []
        , link_res = {
          brands: [],
          categories: []
        }
        , oldKey = "";
      function renderList(isHis, srhInp) {
        var html = ""
          , keyResStr = ""
          , srhInpReg = new RegExp(srhInp, "ig")
          , srhInpMatch = null;
        if (isHis) {
          if (hisList.length == 0) {
            $sug.hide();
            return false
          }
          $sug.show();
          $(".oy-srh_sugHd").show();
          for (var i = 0; i < hisList.length; i++) {
            html += "<li data-index='" + i + "' class='is-his'><a href='javascript:void(0);'>" + decodeURI(hisList[i]) + "</a><em data-index='" + i + "'c-delhis>清除</em></li>"
          }
        } else {
          if (link_res.brands.length == 0 && link_res.categories.length == 0 && key_res.length == 0) {
            $sug.hide();
            return false
          }
          $sug.show();
          $(".oy-srh_sugHd").hide();
          for (var i_0 = 0, arr_0 = link_res.brands; i_0 < arr_0.length; i_0++) {
            html += "<li class='is-link'><a target='_blank' href='" + oy_global.ctx + "/brand/" + arr_0[i_0].id + ".html'><i class='iconfont icon-tags'></i><span>" + decodeURI(arr_0[i_0].name) + "</span>&nbsp;&nbsp;<span class='_txt-mutedEr'>&gt;</span></a></li>"
          }
          for (var i_1 = 0, arr_1 = link_res.categories; i_1 < arr_1.length; i_1++) {
            html += "<li class='is-link'><a target='_blank' href='" + oy_global.ctx + "/category/" + arr_1[i_1].id + ".html'><i class='iconfont icon-catg'></i><span>" + decodeURI(arr_1[i_1].name) + "</span>&nbsp;&nbsp;<span>&gt;</span></a></li>"
          }
          for (var i_2 = 0; i_2 < key_res.length; i_2++) {
            srhInpReg.lastIndex = 0;
            keyResStr = key_res[i_2].key;
            srhInpMatch = srhInpReg.exec(keyResStr);
            if (srhInpMatch !== null) {
              keyResStr = keyResStr.substring(0, srhInpMatch.index) + '<span style="background: #ffff00;">' + keyResStr.substring(srhInpMatch.index, srhInpReg.lastIndex) + "</span>" + keyResStr.substring(srhInpReg.lastIndex)
            }
            html += '<li class="is-key"><a href="javascript:void(0);">' + keyResStr + '</a><span>约<span class="text-primary">' + key_res[i_2].docCount + "</span>条结果</span></li>"
          }
        }
        $list.html(html)
      }
      function doSrh() {
        clearTimeout(intervalFunc);
        intervalFunc = setTimeout(function () {
          var key = $key.val().trim()
            , needLoad = 0;
          if (key.length < 1) {
            key_res = [];
            link_res = {
              brands: [],
              categories: []
            };
            renderList(true, key);
            return false
          }
          if (key == oldKey) {
            $sug.show();
            return false
          }
          oldKey = key;
          needLoad = key.length >= 2 ? 2 : 1;
          $.ajax({
            url: oy_global.soicUrl + "/suggest",
            dataType: "jsonp",
            type: "get",
            data: {
              paramsDTO: JSON.stringify({
                keyword: key
              })
            },
            success: function (data) {
              key_res = data;
              needLoad--;
              if (needLoad === 0) {
                renderList(false, key)
              }
            },
            error: function () { }
          });
          if (key.length >= 2) {
            $.ajax({
              url: oy_global.ctx + "/search/brand_and_category",
              dataType: "json",
              type: "post",
              data: {
                keyword: key
              },
              success: function (data) {
                needLoad--;
                link_res = data;
                if (needLoad === 0) {
                  renderList(false, key)
                }
              }
            })
          }
        }, intervalTime)
      }
      $("#c-srh_clearHis").on("click", function () {
        clearTimeout(hideTimer);
        $list.html("");
        $sug.hide();
        hisList = [];
        localStorage.setItem("srhHistory", JSON.stringify(hisList))
      });
      $list.on("click", ">li", function () {
        if ($(this).hasClass("is-link")) {
          window.open($(this).find("a").attr("href"), "_blank");
          return false
        }
        $key.val($(this).find("a").text());
        $srh.submit()
      });
      $list.on("click", "[c-delhis]", function (e) {
        e.stopPropagation();
        clearTimeout(hideTimer);
        $(this).parent().remove();
        hisList.splice($(this).data("index"), 1);
        localStorage.setItem("srhHistory", JSON.stringify(hisList))
      });
      $key.on("focus", function () {
        doSrh()
      });
      $key.on("blur", function () {
        hideTimer = setTimeout(function () {
          $sug.hide()
        }, 300)
      });
      $key.on("keydown", function (e) {
        var $cur = $list.find(".is-active").eq(0);
        var len = $list.find("li").length;
        switch (e.keyCode) {
          case 38:
            if (!$cur[0] || $cur.index() == 0) {
              $cur.removeClass("is-active");
              $list.find("li").eq(len - 1).addClass("is-active")
            } else {
              $list.find("li").eq($cur.index() - 1).addClass("is-active");
              $cur.removeClass("is-active")
            }
            break;
          case 40:
            if (!$cur[0] || $cur.index() == len - 1) {
              $cur.removeClass("is-active");
              $list.find("li").eq(0).addClass("is-active")
            } else {
              $list.find("li").eq($cur.index() + 1).addClass("is-active");
              $cur.removeClass("is-active")
            }
            break;
          case 13:
            e.preventDefault();
            if ($cur[0]) {
              $cur.trigger("click")
            } else {
              $srh.submit()
            }
            break;
          default:
            doSrh()
        }
      })
    }
    setSrh();
    var searchType = "search";
    var excelFormData = null;
    var excelSubType = "form";
    function setCommonBom() {
      if ($("[c-open-bom]").length == 0)
        return false;
      var html = '<div class="com-diaBg" id="c-bom" style="display: none;">' + '<div class="bomReImDia">' + '<a href="javascript:void(0);" id="c-bom_close" class="com-diaClose icon-x iconfont"></a>' + '<h1>导入BOM<span id="c-bom_dragTip" style="color: #999; font-weight: normal; font-size: 12px;">&nbsp;&nbsp;（<em class="text-warning">可将文件拖拽到此框</em>）</span></h1>' + '<div class="bomReImDia_con" id="c-bom_dragBox">' + '<form action="/bom/match" method="post" id="c-bom_copyForm">' + '<div class="bomImCp-dia">' + '<textarea id="c-bom_copyTxt" name="matchInfo" placeholder="将型号和数量复制到此处，支持多行"></textarea>' + '<input name="supplierId" value="1" type="hidden" />' + '<button id="c-bom_copySub" type="button">开始处理</button>' + "</div>" + "</form>" + '<div class="bomImDemo-dia">示例：AC0201FR-0710KL&nbsp;&nbsp;2500</div>' + '<div class="bomImDia_p">或</div>' + '<form action="/bom/excel_match_ajax" id="c-bom_excelFrom" enctype="multipart/form-data" method="post">' + '<label class="bomImEx-dia" style="cursor: pointer;">' + '<input id="c-bom_subfile" type="file" name="file" accept=".xls,.xlsx,.csv" class="bomImEx-dia_inp">' + '<input name="supplierId" value="1" type="hidden" />' + '<div class="bomImEx-dia_btn"><i class="iconfont icon-export"></i><span>点击上传BOM</span></div>' + '<p class="text-mutedEr">支持csv/xls/xlsx格式文件, <a href="/static/www/assets/excel/bom/BomTemplate.xlsx" class="text-primary">下载BOM模板</a></p>' + "</label>" + "</form>" + "</div>" + "</div>" + '<div class="bomLoad" style="display: none;">' + '<div class="bomLoad_wrd"><img src="' + oy_global.ctx + '/static/www/assets/images/loading.gif">&nbsp;&nbsp;&nbsp;&nbsp;' + "<span>数据加载中...</span>" + "</div>" + "</div>" + "</div>" + '<div id="bom_agree_dia" style="display: none;" class="padding20">' + '<div class="register-agreement">' + '<div class="agreement-label">尊敬的用户，您好！请您务必仔细阅读并确保您已经充分理解协议所写明的条款内容，让您可以按照指引做出您认为适当的选择。以下内容为《BOM使用条款》：</div>' + '<div class="agreement-cont">' + '<h2 class="agreementTit0">BOM使用条款</h2>' + "<p><b>1、BOM免责声明</b><br>&emsp;&emsp;1.1  BOM配单是由唯样免费提供的选型工具，匹配结果中推荐的商品型号可能会存在一定的误差，匹配表单中已做了相应的风险提示，<b>下单前，请务必认真核对推荐商品型号是否真实所需，请核实无误后再提交订单</b>。<br><br><b>2、BOM文件的识别</b><br>&emsp;&emsp;2.1  唯样BOM配单只支持上传CSV/xls/xlsx格式的Excel文件，若Excel文件中有多个“Sheet”,只识别第一个Sheet，请务必将需要识别的内容放在第一个Sheet中。<br>&emsp;&emsp;2.2  唯样BOM配单是根据表单中表头的关键字进行判断型号列、参数列、数量列和品牌列，有一定的误判率，请根据弹窗提示选择相应的列。<br>&emsp;&emsp;2.3  为了提高匹配的准确率，您可使用唯样提供的BOM模板，按要求填写BOM数据后，再上传BOM进行匹配。<br><br><b>3、BOM匹配范围</b><br>&emsp;&emsp;3.1  唯样BOM配单数据来源于唯样现有的数据，其中包含唯样自营和海外代购两部分，默认优先匹配唯样自营商品，您也可以匹配结果中选择匹配海外代购，匹配海外代购有一定的延时性，请耐心等待。<br><br><b>4、BOM匹配结果</b><br>&emsp;&emsp;4.1  根据匹配结果分为推荐商品和无法匹配：推荐商品是指有匹配到商品，其中包含完全匹配和部分匹配，完全匹配是指需求型号和推荐型号一致，部分匹配是指根据参数匹配推荐的，有部分参数略有不同，不同部分会有红字标明；无法匹配是指无匹配结果，可通过调整需求参数进行二次匹配。<br>&emsp;&emsp;4.2  根据库存提示分为库存不足和MOQ限制：库存不足是指需求数量大于唯样商品库存，下单前请先咨询在线销售；MOQ限制是指需求数量大于最小起订量， 系统会自动将数量调整为最小起订量，下单前请务必核实MOQ限制，确认需求数量。<br>&emsp;&emsp;4.3  匹配结果可通过“导出报价结果”形成一份唯样商城报价单，由于商品的库存和价格有一定的时效性，报价单中的库存和价格不代表最终报表，请以商城实际价格为准。<br><br><b>5、BOM风险提示</b><br>&emsp;&emsp;5.1  匹配结果中推荐商品的型号与参数若有和原始需求型号与参数不同，将会有红色标出，请务必认真核对商品。<br>&emsp;&emsp;5.2  匹配结果中推荐商品的型号与原始需求型号一致（即完全匹配），会自动勾选，但仍需要核实后，再加入购物车。<br>&emsp;&emsp;5.3  匹配结果中推荐商品的型号与参数若有和原始需求型号与参数不同（即部分匹配），默认为不勾选，需要手动勾选，勾选时会弹出“风险提示”窗口，请认真阅读风险提示后确认选择。<br>&emsp;&emsp;5.4  勾选部分匹配的商品后，加入购物车时，会弹出“风险提示”窗口，请认真阅读风险提示后确认加入购物车；</p>" + "</div>" + '<div class="agreement-groups">' + '<a href="javascript:;" class="agreement-btn disagree-btn bom-disagree">不同意</a>' + '<a href="javascript:;" class="agreement-btn agree-btn bom-agree">已阅读并同意继续</a>' + "</div>" + "</div>" + "</div>";
      $("body").append(html);
      $("[c-open-bom]").on("click", function () {
        $("#c-bom").show()
      });
      $("#c-bom_close").on("click", function () {
        $("#c-bom").hide()
      });
      if (window.FormData && window.XMLHttpRequest) {
        var dragExcel = $("#c-bom_dragBox")[0];
        var preventDrag = function (event) {
          event.preventDefault();
          event.stopPropagation();
          return false
        };
        dragExcel.addEventListener("dragenter", function (event) {
          event.preventDefault();
          return false
        }, false);
        dragExcel.addEventListener("dragover", preventDrag, false);
        dragExcel.addEventListener("dragleave", function (event) {
          event.preventDefault();
          return false
        }, false);
        excelFormData = new FormData;
        dragExcel.addEventListener("drop", function (event) {
          event.stopPropagation();
          event.preventDefault();
          var files = event.dataTransfer.files;
          if (files.length > 1) {
            layer.msg("一次只能上传一个BOM表单!", {
              icon: 2
            });
            return false
          }
          var file = files[0];
          if (!/.csv$|.xls$|.xlsx$/.test(file.name)) {
            layer.msg("请上传.csv、.xls、.xlsx类型文件！", {
              icon: 2
            });
            return false
          }
          var fileSzie = (file.size / 1024).toFixed(2);
          if (fileSzie >= 4096) {
            layer.alert("文件大小必须小于4MB");
            return false
          }
          excelFormData.append("file", file, file.name);
          excelFormData.append("supplierId", "1");
          excelSubType = "excelSubType";
          searchType = "drag";
          openAgreeDia();
          return false
        }, false);
        window.addEventListener("dragenter", preventDrag, false);
        window.addEventListener("dragover", preventDrag, false);
        window.addEventListener("dragleave", preventDrag, false);
        window.addEventListener("drop", preventDrag, false)
      } else {
        $("#c-bom_dragTip").remove()
      }
      $("#c-bom_subfile").on("change", function (event) {
        var _this = this;
        var fileSzie = (event.target.files[0].size / 1024).toFixed(2);
        if (fileSzie >= 4096) {
          layer.alert("文件大小必须小于4MB");
          return false
        }
        if (!this.value) {
          layer.msg("请上传文件!", {
            icon: 2
          });
          return false
        }
        excelSubType = "form";
        searchType = "drag";
        openAgreeDia()
      });
      $("#c-bom_copySub").on("click", function () {
        if ($("#c-bom_copyTxt").val().trim() === "") {
          layer.msg("请填入需要匹配的型号", {
            icon: 2
          });
          return false
        }
        searchType = "search";
        openAgreeDia()
      });
      $("#c-bom_copyTxt").on("keyup", function () {
        $("#c-bom_copyTxt").height(22 * $("#c-bom_copyTxt").val().split("\n").length)
      });
      $(".bom-disagree").on("click", function () {
        layer.close(lyIndex);
        $("#c-bom_subfile").val("");
        excelFormData = new FormData
      });
      $(".bom-agree").on("click", function () {
        layer.close(lyIndex);
        if (searchType == "search") {
          perfromCopyForm()
        } else {
          subExcelForm()
        }
      })
    }
    setCommonBom();
    var lyIndex;
    function openAgreeDia() {
      lyIndex = layer.open({
        type: 1,
        title: "唯样商城《BOM使用条款》及意愿确认",
        content: $("#bom_agree_dia"),
        closeBtn: 0,
        area: ["760px", "560px"]
      })
    }
    function perfromCopyForm() {
      $(".bomLoad").show();
      $.ajax({
        url: oy_global.ctx + "/bom/match",
        type: "post",
        data: {
          matchInfo: $("#c-bom_copyTxt").val(),
          supplierId: "1"
        }
      }).done(function (data) {
        if (data.code == 200) {
          window.location.href = data.message
        } else {
          $(".bomLoad").hide();
          layer.msg(data.message, {
            icon: 2
          })
        }
      })
    }
    function subExcelForm() {
      if (excelSubType == "form") {
        $(".bomLoad").show();
        $("#c-bom_excelFrom").ajaxSubmit({
          dataType: "json",
          success: function (data) {
            if (data.code == 200) {
              window.location.href = data.message
            } else {
              layer.msg(data.message, {
                icon: 2
              });
              $(".bomLoad").hide();
              $("#c-bom_subfile").val("")
            }
          },
          error: function () {
            $(".bomLoad").hide();
            layer.msg("系统未知错误，请重试！", {
              icon: 2
            });
            $("#c-bom_subfile").val("")
          }
        })
      } else {
        $(".bomLoad").show();
        $.ajax({
          url: oy_global.ctx + "/bom/excel_match_ajax",
          type: "post",
          data: excelFormData,
          dataType: "json",
          contentType: false,
          processData: false
        }).done(function (data) {
          $(".bomLoad").hide();
          if (data.code == 200) {
            window.location.href = data.message
          } else {
            layer.msg(data.message, {
              icon: 2
            })
          }
        })
      }
    }
    function addMenuActive() {
      var $nav = $("[menu-itm-active-class]");
      if (!$nav[0])
        return false;
      var browserLocation = document.location.pathname + document.location.search;
      var isAddClassActive = false;
      if (browserLocation == "" || browserLocation == "/" || browserLocation == "/index.html") {
        $nav.find("a").eq(0).addClass("is-active");
        return
      }
      if (browserLocation == "/account/index" || browserLocation == "/account/index.html") {
        return
      }
      $nav.find("a").each(function (index, element) {
        if ($(element).attr("href") != "" && $(element).attr("href") == browserLocation) {
          $(element).addClass("is-active");
          isAddClassActive = true
        }
      });
      if (!isAddClassActive) {
        $nav.find("a").each(function (index, element) {
          if ($(element).attr("href") != "" && $(element).attr("href") == document.location.pathname) {
            $(element).addClass("is-active");
            isAddClassActive = true
          }
        })
      }
    }
    addMenuActive()
  };
  var setFoot = function setFoot() {
    var $itm = $(".footer-lnk.nav-con-tab");
    $itm.find(">.tab-head").on("click", ">li", function () {
      $(this).addClass("is-active").siblings(".is-active").removeClass("is-active");
      $itm.find(".tab-pane").removeClass("is-active");
      $itm.find(".tab-pane").eq($(this).data("index")).addClass("is-active")
    })
  };
  function setProsNav() {
    if ($(".oy-catg").length == 0)
      return false;
    var $allNav = $(".oy-catg").eq(0);
    var i = 0
      , list = COMMON_PRODUCT_CATES
      , picLinkMap = {
        1102: "/page/picture_category_connector.html",
        1566: "/page/picture_category_switch.html"
      }
      , output = "";
    for (; i < list.length; i++) {
      var cate = list[i];
      if (!cate.displayIndex)
        continue;
      output += '<div class="oy-catgs_lv1">';
      output += '<h2 class="' + (picLinkMap[cate.urlId] ? "is-picture" : "") + '">';
      output += '<a href="' + oy_global.ctx + "/category/" + cate.urlId + '.html">';
      output += '<i class="proIcn proIcn-' + cate.id + '"></i>' + cate.name + (cate.docCount ? "(" + cate.docCount + ")" : "");
      output += "</a>";
      if (picLinkMap[cate.urlId]) {
        output += '<a href="' + oy_global.ctx + picLinkMap[cate.urlId] + '" class="_link-pic"><i class="iconfont icon-picture"></i><span>选型</span><i class="iconfont icon-arr-r"></i></a>'
      }
      output += "</h2>";
      output += '<div class="oy-catgs_lv2">';
      if (!!cate.childCategories) {
        for (var j = 0, child = cate.childCategories; j < child.length; j++) {
          child[j].displayIndex && (output += '<a href="' + oy_global.ctx + "/category/" + child[j].urlId + '.html">' + child[j].name + "</a>")
        }
      }
      output += "</div></div>"
    }
    output += '<a class="oy-catgs_more" href="' + oy_global.ctx + '/search/product_category.html">查看全部分类&nbsp;&nbsp;<i class="iconfont icon-triangle--rgtBd"></i></a>';
    $(".oy-catgs_mian").html(output);
    var allNavHeight = $(".oy-catgs_mian").outerHeight();
    $allNav.on("mouseover", function () {
      $(this).addClass("is-hover")
    });
    $allNav.on("mouseleave", function () {
      $(this).removeClass("is-hover")
    });
    $allNav.find(".oy-catgs_lv1").on("mouseover", function (e) {
      var $this = $(this);
      var posTop = $this.position().top;
      var $lv2 = $this.find(".oy-catgs_lv2");
      $this.addClass("is-active");
      if ($lv2.outerHeight() > allNavHeight) {
        $lv2.css({
          top: -posTop + "px"
        })
      } else if (posTop + $lv2.outerHeight() < allNavHeight) {
        $lv2.css({
          top: "0px"
        })
      } else {
        $lv2.css({
          top: allNavHeight - $lv2.outerHeight() - posTop + "px"
        })
      }
      e.stopPropagation()
    }).on("mouseleave", function () {
      $(this).removeClass("is-active")
    })
  }
  function countCart() {
    $.ajax({
      url: oy_global.ctx + "/cart/count",
      success: function (data) {
        if (data > 0) {
          $("#shopCartNum").addClass("is-show").text("" + data + "");
          $("[common_cart_num]").addClass("is-show").text(data)
        } else {
          $("#shopCartNum").removeClass("is-show").text("" + data + "");
          $("[common_cart_num]").removeClass("is-show").text(data)
        }
      }
    })
  }
  window.countCart = countCart;
  function setPromo() {
    if ($(".oy-promo_img").length === 0)
      return false;
    var $promo = $(".oy-promo_img")
      , $img = $promo.find("img")
      , $a = $promo.find("a")
      , $close = $promo.find(".icon-x");
    $img.on("load", function () {
      $img.css({
        "margin-left": "-" + this.width / 2 + "px"
      });
      $a.css({
        height: this.height + "px"
      });
      $promo.css({
        height: this.height + "px"
      })
    });
    $img.attr("src", $img.attr("data-src"));
    $close.on("click", function () {
      $promo.css({
        height: "0"
      });
      $promo.remove()
    })
  }
  var ie8Tip = function ie8Tip() {
    if (!utils.isIE(8))
      return false;
    $("body").prepend("<div style='background: #f49b6d;color:#fff;'><div style='max-width: 1200px;min-width: 960px;margin:0 auto;padding:15px 0;line-height: 24px;font-size: 16px'><p>您的浏览器版本过低（IE8及IE8以下的浏览器或者其他浏览器的兼容模式），存在严重安全漏洞，请切换浏览器为极速模式或者将IE浏览器升级到更高版本。</p><p>推荐您下载并使用：<a style='text-decoration:underline' rel='nofollow' target='_blank' href='https://www.google.cn/chrome/'>谷歌浏览器</a>、 <a style='text-decoration:underline' rel='nofollow' target='_blank' href='http://www.firefox.com.cn/'>火狐浏览器</a>、 <a style='text-decoration:underline' rel='nofollow' target='_blank' href='https://browser.360.cn/'>360浏览器</a>、 <a style='text-decoration:underline' rel='nofollow' target='_blank' href='https://ie.sogou.com/'>搜狗浏览器</a>、 <a style='text-decoration:underline' rel='nofollow' target='_blank' href='https://browser.qq.com/'>QQ浏览器</a> 的极（高）速模式进行访问。</p></div>")
  };
  $(function () {
    setPromo();
    ie8Tip();
    initPageEvents();
    setPlaceHolder();
    setTopBar();
    countCart();
    setProsNav();
    setFoot();
    initCartPreview();
    if (utils.isIE(8) || utils.isIE(9)) {
      setTimeout(function () {
        $("input, textarea").placeholder()
      }, 30)
    }
  })
}
)();
(function () {
  var isProcessing = false;
  var buyDialog = function buyDialog(opts) {
    if (isProcessing)
      return false;
    isProcessing = true;
    var opts = $.extend({
      stkCode: "",
      before: function () { },
      after: function () { },
      callback: function () { }
    }, opts);
    opts.before();
    $.ajax({
      url: oy_global.ctx + "/product/buy_dialog/judgeCanBuy",
      datatype: "json",
      type: "post",
      data: {
        stkCode: opts.stkCode
      },
      success: function (data) {
        if (data.success) {
          $.ajax({
            url: oy_global.ctx + "/product/buy_dialog/detail.html",
            dataType: "html",
            data: {
              stkCode: opts.stkCode
            },
            success: function (result) {
              $("body").append(result);
              opts.after();
              opts.callback();
              isProcessing = false
            },
            error: function () {
              isProcessing = false
            }
          })
        } else {
          isProcessing = false;
          layer.msg(data.message, {
            icon: 2
          });
          opts.after()
        }
      },
      error: function () {
        isProcessing = false;
        layer.alert(data.message);
        opts.after()
      }
    })
  };
  function show(opts) {
    var cartCount = parseInt($("#shopCartNum").text());
    if (cartCount > 2) {
      wyComponent.login.show(function () {
        buyDialog(opts)
      })
    } else {
      buyDialog(opts)
    }
  }
  window.showBuyDialog = show
}
)();
